package controller;

import cn.edu.zut.model.Reader;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.ui.Model;

@Controller
public class TestController {
//    @RequestMapping("/showUser")
//    public String showUser(){
//        return "ShowUser";
//    }

    @RequestMapping(value = "/{userId}/showUser" ,method = RequestMethod.GET)
    public ModelAndView showUser(@PathVariable String userId){
        System.out.println("show "+userId);
        return new ModelAndView("ShowUser","message","test message!");
    }
    @RequestMapping(value = "/addUser" ,method = RequestMethod.POST)
    public ModelAndView addUser(Model model,String name,Integer age){
        System.out.println("name "+name+" age: "+age);
        return new ModelAndView("ShowUser","message","test message!");
    }
    @RequestMapping(value = "/addUser1" ,method = RequestMethod.POST)
    public ModelAndView addUser1(Model model, Reader reader){
        System.out.println("name "+reader.getName()+" age: "+reader.getAge());
        Reader reader1=new Reader();
        reader1.setName(reader.getName());
        return new ModelAndView("ShowUser","reaader1","test message!");
    }
}
